% 给定参数
ship_length = 100; % meters
ship_width = 20; % meters
ship_draft = 10; % meters
ship_displacement = 10000; % tons
drag_coefficient = 0.5;
windage_area = 100; % square meters
propulsion_force = 100000; % newtons

% 创建船舶模型
ship = ShipModel(ship_length, ship_width, ship_draft, ship_displacement, drag_coefficient, windage_area, propulsion_force);

% 环境参数
wind_speed = 10; % meters/second
wind_direction = pi/4; % radians (northeast)
current_speed = 2; % meters/second
current_direction = pi/3; % radians (northeast)

% 创建环境模型
environment = EnvironmentModel(wind_speed, wind_direction, current_speed, current_direction);

% 仿真参数
simulation_time = 300; % seconds
time_step = 0.01; % seconds

% 存储仿真数据
position = zeros(3, simulation_time/time_step + 1);
velocity = zeros(3, simulation_time/time_step + 1);
acceleration = zeros(3, simulation_time/time_step + 1);

% 仿真循环
for i = 1:(simulation_time/time_step + 1)
    t = (i - 1) * time_step;
    
    % 计算力
    wind_force = ship.calculate_wind_force(environment.wind_speed, environment.wind_direction);
    current_force = ship.calculate_current_force(environment.current_speed, environment.current_direction);
    wave_force = ship.calculate_wave_force(t);
    other_forces = ship.calculate_propulsion_force();
    
    % 计算运动学
    ship.calculate_kinematics(wind_force, current_force, wave_force, other_forces, time_step);
    
    % 记录数据
    position(:, i) = ship.position;
    velocity(:, i) = ship.velocity;
    acceleration(:, i) = ship.acceleration;
end

% 绘制轨迹图
figure;
plot3(position(1, :), position(2, :), -position(3, :), 'b-');  % 修改为 '-position(3, :)'
xlabel('X (meters)');
ylabel('Y (meters)');
zlabel('Z (meters)');
title('Ship Trajectory');